﻿using System.Runtime.Serialization;

namespace ClientOverflow.DataTransferObjects
{
    /// <summary>
    /// Tag class is a DTO representing a tag in the server side. The tag can be related to a question or to 
    /// an answer.
    /// The class is decorated with [DataContract] attribute and the properties are decorated with
    /// [DataMember] attributes. Using the decorations the class is compatible as data trasnfer object
    /// in the WCF service.
    /// </summary>
    [DataContract]
    public class Tag
    {
        [DataMember]
        public string Name { get; set; }

        public bool Equals(Tag other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.Name, Name);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Tag)) return false;
            return Equals((Tag) obj);
        }

        public override int GetHashCode()
        {
            return (Name != null ? Name.GetHashCode() : 0);
        }
    }
}